def bubble_sort(arr):
    n = len(arr)
    count = 0
    for i in range(n): #0<=i<n
        for j in range(0, n - i - 1): #0<=j<n-i-1
            count += 1
            if arr[j] > arr[j + 1]:
                (arr[j], arr[j + 1]) = (arr[j + 1], arr[j])
    print(f"bubble_sort 函数中的比较操作次数: {count}")
    return arr

arr = [5, 4, 3, 2, 1]
sorted_arr = bubble_sort(arr)
print(sorted_arr)